package com.edmendst.xmall.config;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JacksonConfig {

    @Bean
    public ObjectMapper objectMapper() {
        return new ObjectMapper()
                // 自动将 JSON 的蛇形命名转为 Java 驼峰命名
                .setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
                // 自动将浮点数反序列化为 BigDecimal
                .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
    }
}